home *** CD-ROM | disk | FTP | other *** search
- ;%%%%%%%%%%%%%%%%%%%%%%%%
- ;script Notes support
- ;version 7.20
- ;author BARtMAN, Quietust
- ;email bartman@ircN.org
- ;url http://www.ircN.org
- ;%%%%%%%%%%%%%%%%%%%%%%%%
- on 1:CONNECT {
- if (%cn.time == $null) set %cn.time 3600
- .timer 0 %cn.time notes.check
- }
- on 1:START {
- if ($exists(notes.dat) == $false) write -c notes.dat
- notes.expire
- }
- alias notes.expire {
- var %a, %b, %z
- set %a 1
- while ($read -nl $+ %a notes.dat != $null) {
- set %z $ifmatch
- if ($calc($ctime - (86400 * 30)) >= $gettok(%z,3,32)) {
- inc %b
- write -dl $+ %a notes.dat
- dec %a
- }
- inc %a
- }
- if (%b != $null) iecho %b $iif(%b == 1,note was,notes were) 30 days or more old and have been deleted.
- }
- on 1:JOIN:# {
- if (%notes.sent. [ $+ [ $nick ] ] ) return
- var %a, %b, %y, %z
- set %y $usrh($fulladdress)
- set %a 1
- while ($read -nl $+ %a notes.dat != $null) {
- set %z $gettok($ifmatch,1,32)
- if (%z == %y) inc %b
- inc %a
- }
- if (%b != $null) {
- .notice $nick You have %b $iif(%b == 1,note,notes) waiting on $me $+ .
- .notice $nick For a list, /CTCP $me NOTES [pass] INDEX
- }
- set -u30 %note.sent. [ $+ [ $nick ] ] $true
- }
- ctcp 40:NOTES *:? {
- var %z = $usrh($fulladdress)
- if ($2 === $password(%z)) {
- if ($3 == index) notes.index %z $nick
- elseif ($3 == read) notes.read %z $nick $4
- elseif ($3 == erase) notes.erase %z $nick $4
- elseif ($3 == to) notes.to %z $nick $4-
- }
- }
- alias -l notes.index {
- var %a, %b, %z
- set %a 1
- while ($read -nl $+ %a notes.dat != $null) {
- set %z $ifmatch
- if ($gettok($ifmatch,1,32) == $1) {
- inc %b
- .notice $2 $lfix(3,%b) $+ . $gettok(%z,2,32) ( $+ $asctime($gettok(%z,3,32),mmm d H:ss z) GMT)
- }
- inc %a
- }
- if (%b != $null) .notice $2 ( $+ %b total)
- else .notice $2 You have no messages.
- }
- alias -l notes.read {
- var %a, %b, %y, %z
- set %y $notes.num($3)
- set %a 1
- while ($read -nl $+ %a notes.dat != $null) {
- set %z $ifmatch
- if ($1 == $gettok(%z,1,32)) {
- inc %b
- if (($3 == all) || ($3 == $null) || ($istok(%y,%b,32) == $true)) .notice $2 $lfix(3,%b) $+ . $gettok(%z,2,32) ( $+ $asctime($gettok(%z,3,32),mmm d H:ss z) GMT): $gettok(%z,4-,32)
- }
- inc %a
- }
- if (%b == $null) .notice $nick You have no messages.
- }
- alias -l notes.erase {
- var %a, %b, %c, %y, %z
- set %y $notes.num($3)
- set %a 1
- while ($read -nl $+ %a notes.dat != $null) {
- set %z $gettok($ifmatch,1,32)
- if (%z == $1) {
- inc %b
- if (($3 == all) || ($3 == $null) || ($istok(%y,%b,32) == $true)) {
- write -dl $+ %a notes.dat
- dec %a
- inc %c
- }
- }
- inc %a
- }
- if (%c != $null) {
- if (%c == %b) .notice $2 Erased all notes.
- else .notice $2 Erased %c $iif(%c == 1,note,notes) $+ ; $calc(%b - %c) left.
- }
- else .notice $nick You have no messages.
- }
- alias -l notes.to {
- if ($usrhost($3) == $null) {
- if ($usr($3) != $null) .notice $2 No such username; try $ifmatch $+ .
- else .notice $2 No such username!
- }
- elseif ($4 == $null) .notice $2 Syntax: /ctcp $me NOTES TO <username> <message>
- elseif ($usrhost($3) != $null) {
- write notes.dat $3 $1 $ctime $4-
- .notice $2 Note delivered.
- }
- }
- alias notes.check {
- var %a, %b, %c, %d, %e, %v, %w, %x, %y, %z
- set %a 1
- while ($read -nl $+ %a notes.dat != $null) {
- set %z $usrhost($gettok($ifmatch,1,32))
- set %b 1
- while ($gettok(%z,%b,32) != $null) {
- set %y $ifmatch
- set %c 1
- while ($ial(%y,%c).nick != $null) {
- set %x $ifmatch
- if ($wildtok(%w,$addtok(%x,*,44),1,32) != $null) set %w $reptok(%w,$ifmatch,$addtok(%x,$calc($gettok($ifmatch,2,44) + 1),44),1,32)
- else set %w $addtok(%w,$addtok(%x,1,44),32)
- inc %c
- }
- inc %b
- }
- inc %a
- }
- set %d 1
- while ($gettok(%w,%d,32) != $null) {
- set %v $gettok($ifmatch,1,44)
- set %e $gettok($ifmatch,2,44)
- .timer 1 %d .notice %v You have %e $iif(%e == 1,note,notes) waiting on $me $+ .
- .timer 1 $calc(%d + 1) .notice %v For a list, /CTCP $me NOTES [pass] INDEX
- inc %d
- }
- }
- alias notes.num {
- var %a, %y, %z
- set %a 1
- while (%a <= $iif($2 != $null,$2,25)) {
- set %y %y %a
- inc %a
- }
- set %a 1
- while ($gettok($1,%a,59) != $null) {
- set %z %z $gettok(%y,$ifmatch,32)
- inc %a
- }
- return %z
- }
-